# 不单独使用，配合dynamicLayer一起用。
from core.LiuYao import LiuYaoPlace
from core.engine.DictTensor import DictTensor

def print_dict_tensor(gua_dict):
    # 打印所有属性
    tensor = DictTensor(gua_dict)


    print('本位动爻被变爻的生克，伏神被飞神的生克（0-为扶，1为生，2为克）:\n',tensor.wx_alter())
    print('变爻对本位动爻的五行关系序数\n',tensor.wx_alter())
    print(tensor.wx_vary(2))
    print('变爻对本位动爻的地支关系序数\n',tensor.zhi_alter('zhiDiff'))
    print(tensor.zhi_vary('zhiDiff',1))

    # 获取对象的所有属性名
    attributes = [attr for attr in dir(tensor) if not attr.startswith('__') and not callable(getattr(tensor, attr))]

    # 打印每个属性的值
    for attr in attributes:
        if getattr(tensor, attr) is not None and not attr.startswith('_'):
            print(f"【{attr}】: {getattr(tensor, attr)}")


def by_AFD():
    print('*' * 40, 'CoinNum:', '132121', '*' * 40)
    lyp = LiuYaoPlace.from_params('132121', solartime='2021-01-01 03:24:00', title='my title')
    print(lyp.gua)
    lyp.place(output=True)
    print_dict_tensor(lyp.gua)

def by_dict():
    from test_cases import gua_dicts
    # for gua_dict in gua_dicts:
    gua_dict = gua_dicts[0]
    lyp = LiuYaoPlace(gua_dict)
    lyp.place(output=True)
    print_dict_tensor(gua_dict)

if __name__ == '__main__':
    print('*'*40,'AFD','*'*40)
    by_AFD()
    print('*'*40,'dict','*'*40)
    by_dict()
